package cn.qdhlm.collectservice.core.component.command;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import lombok.extern.log4j.Log4j2;

/**
 * @Name: CmdAfn0a
 * @Description: 1类数据
 * @Author: jiangcs
 */
@Log4j2
public class CmdAfn0a {
    /**
     * 实时数据
     *
     * @param sn
     */
    public static ByteBuf f1(int sn) {
        ByteBuf byteBuf = Unpooled.buffer(2);
        // 数据单元标识：FN
        byteBuf.writeByte(0x01);
        // 数据包序号
        byteBuf.writeByte(sn);
        return Unpooled.wrappedBuffer(packDefault(), byteBuf);
    }

    /**
     * 命令包：默认
     *
     * @return
     */
    private static ByteBuf packDefault() {
        ByteBuf byteBuf = Unpooled.buffer(2);
        // 功能码：AFN
        byteBuf.writeByte(0x0a);
        // 帧序列：SEQ，默认FF
        byteBuf.writeByte(0xFF);
        return byteBuf;
    }
}
